<script setup>
  import { ref } from "vue";
  import { onLoad } from '@dcloudio/uni-app'
  import { truckApi } from "../../apis/user";
  // 车辆信息
  const truchInfo = ref({})

  // 获取车辆信息
  async function getTruckInfo() {
    const { code, data } = await truckApi()
    // 检测接口否调用成功
    if (code === 200) {
      // 渲染请求来的数据
      truchInfo.value = data
    }
  }
  onLoad(() => {
    getTruckInfo()
  })
</script>

<template>
  <view class="page-container">
    <swiper class="truck-pictures" indicator-active-color="#fff" circular indicator-dots>
      <swiper-item v-for="picture in truchInfo.pictureList">
        <image class="picture" mode="aspectFill" src="/static/uploads/truck_picture.jpg"></image>
      </swiper-item>

    </swiper>
    <view class="truck-meta">
      <uni-list :border="false">
        <uni-list-item :border="false" title="车辆编号" :rightText="truchInfo.id" />
        <uni-list-item :border="false" title="车辆号牌" :rightText="truchInfo.licensePlate" />
        <uni-list-item :border="false" title="车型" :rightText="truchInfo.truckType" />
        <uni-list-item :border="false" title="所属机构" :rightText="truchInfo.currentOrganName" />
        <uni-list-item :border="false" title="载重" :rightText="truchInfo.allowableLoad" />
      </uni-list>
    </view>
  </view>
</template>

<style lang="scss" scoped>
  @import './index.scss';
</style>